package com.yuandian.bpm.common.data.datascope;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 说明：bpm数据权限范围
 * @Author zfsn
 * @Date 2023/2/14 9:59
 */
@Data
public class BpmScope implements Serializable {

	/**
	 * 系统id字段名
	 */
	private String systemIdFieldName = "system_id";

	/**
	 * 业务编码字段名
	 */
	private String businessCodeFieldName = "business_code";

	/**
	 * 步骤编码字段名
	 */
	private String stepCodeFieldName = "step_code";

	/**
	 * 具体的权限范围
	 * system_id
	 * business_code
	 * step_code
	 */
	private Map<String, List<?>> permissionMap = new HashMap<>();

	/**
	 * 函数名称，默认 SELECT *
	 */
	private DataScopeFuncEnum func = DataScopeFuncEnum.ALL;

	/**
	 * 获取实例
	 * @return bpm数据权限范围
	 */
	public static BpmScope of() {
		return new BpmScope();
	}

	public BpmScope systemIdFieldName(String systemIdFieldName) {
		this.systemIdFieldName = systemIdFieldName;
		return this;
	}

	public BpmScope businessCodeFieldName(String businessCodeFieldName) {
		this.businessCodeFieldName = businessCodeFieldName;
		return this;
	}

	public BpmScope stepCodeFieldName(String stepCodeFieldName) {
		this.stepCodeFieldName = stepCodeFieldName;
		return this;
	}

	public BpmScope systemId(List<Integer> systemIdList) {
		this.permissionMap.put(systemIdFieldName, systemIdList);
		return this;
	}

	public BpmScope businessCode(List<String> businessCodeList) {
		this.permissionMap.put(businessCodeFieldName, businessCodeList);
		return this;
	}

	public BpmScope stepCode(List<String> stepCodeList) {
		this.permissionMap.put(stepCodeFieldName, stepCodeList);
		return this;
	}
}
